# Tanım: Ofis Programı
# URL: http://www.libreoffice.org/
# Paketçi: Cihan Alkan
# Gerekler: hunspell python3 libwpd neon pango nspr clucene openjdk xmlsec libodfgen libwps libvisio libcdr libmspub libmwaw libe-book libabw libzmf libpagemaker libcmis cppunit libtommath  graphite2 harfbuzz redland raptor hyphen mythes lpsolve libexttextcat liborcus beanshell libpng cairo apache-ant junit libetonyek openldap sane bluez poppler cups libatomic-ops gperf gtk2 gtk3 perl-archive-zip perl-xml-parser boost expat gstreamer-plugins-base gstreamer1-plugins-base libgsf librsvg libxml2 libxslt nss postgresql icu gsfonts dejavu-ttf npapi-sdk serf unixodbc xdg-utils desktop-file-utils gpgme
# Grup: ofis

isim=libreoffice
surum=6.1.0.3
_surum=6.1.0
devir=1

kaynak=(https://download.documentfoundation.org/libreoffice/src/${_surum}/$isim-$surum.tar.xz
		https://download.documentfoundation.org/libreoffice/src/${_surum}/$isim-dictionaries-$surum.tar.xz
		https://download.documentfoundation.org/libreoffice/src/${_surum}/$isim-help-$surum.tar.xz
		https://download.documentfoundation.org/libreoffice/src/${_surum}/$isim-translations-$surum.tar.xz
		https://kaynaklar.milislinux.org/libreofis-milis-ekler.tar.xz)

derle() {
        unset ACLOCAL
        export LO_PREFIX=/usr

	#cd $SRC
	#tar -xf $isim-$surum.tar.xz --no-overwrite-dir

	cd $isim-$surum

	install -dm755 external/tarballs
	ln -sv $SRC/$isim-dictionaries-$surum.tar.xz  external/tarballs/
	ln -sv $SRC/$isim-help-$surum.tar.xz          external/tarballs/
        ln -sv $SRC/$isim-translations-$surum.tar.xz  external/tarballs/


        sed -e "/gzip -f/d"   \
            -e "s|.1.gz|.1|g" \
            -i bin/distro-install-desktop-integration

        sed -e "/distro-install-file-lists/d" -i Makefile.in


	chmod -v +x bin/unpack-sources

./autogen.sh --prefix=$LO_PREFIX         \
             --sysconfdir=/etc           \
             --with-vendor="Milis Linux" \
             --with-lang="tr"            \
             --with-help                 \
             --with-myspell-dicts        \
             --with-alloc=system         \
             --without-junit             \
             --without-system-dicts      \
             --disable-dconf             \
             --enable-odk                \
		     --with-jdk-home="/opt/jdk"  \
       		 --with-ant-home="/opt/ant"  \
             --disable-firebird-sdbc     \
             --enable-release-build=yes  \
             --enable-python=system      \
             --with-system-apr           \
             --with-system-boost         \
             --with-system-clucene       \
             --with-system-cairo         \
             --with-system-curl          \
             --with-system-expat         \
             --with-system-icu           \
             --with-system-jpeg          \
             --with-system-lcms2         \
             --with-system-libatomic_ops \
             --with-system-libpng        \
             --with-system-libxml        \
	         --with-system-libodfgen     \
		     --with-system-libmwaw       \
		     --with-system-libetonyek    \
		     --with-system-libvisio      \
		     --with-system-libcmis       \
		     --with-system-libmspub      \
		     --with-system-libexttextcat \
		     --with-system-orcus \
		     --with-system-liblangtag \
             --with-system-neon          \
             --with-system-nss           \
             --with-system-odbc          \
             --with-system-openldap      \
             --with-system-openssl       \
             --with-system-poppler       \
             --with-system-postgresql    \
             --with-system-redland       \
             --with-system-serf          \
             --with-system-zlib          \
		     --with-system-beanshell \
		     --with-system-cppunit\
		     --with-system-graphite\
		     --with-system-harfbuzz\
		     --with-system-glm \
		     --with-system-libwpg \
		     --with-system-libwps \
		     --with-system-libzmf \
		     --with-system-gpgmepp \
             --with-parallelism=$(getconf _NPROCESSORS_ONLN)
	make -i build-nocheck
	make -i DESTDIR=$PKG distro-pack-install

	install -v -m755 -d $PKG/$LO_PREFIX/share/appdata
	install -v -m644    sysui/desktop/appstream-appdata/*.xml $PKG/$LO_PREFIX/share/appdata

	# Sözlük kurulumu
	chown -cR 0:0 dictionaries/ 
	for lang in en
	do
	  mkdir -pv $PKG/$LO_PREFIX/lib/libreoffice/share/extensions/dict-$lang
	  cp -R dictionaries/$lang/* $PKG/$LO_PREFIX/lib/libreoffice/share/extensions/dict-$lang
	done

	# Bu sembolik bağ, masaüstü menü girdileri için gereklidir
	ln -sv -f $LO_PREFIX/lib/libreoffice/program/soffice \
	$PKG/usr/bin/libreoffice

	# Simgeler
	for res in 16 32 48 128 256
	do
	  mkdir -p $PKG/$LO_PREFIX/share/icons/hicolor/${res}x${res}/{apps,mimetypes}
	  cp sysui/desktop/icons/hicolor/${res}x${res}/apps/*.png \
	  	$PKG/$LO_PREFIX/share/icons/hicolor/${res}x${res}/apps
	  cp sysui/desktop/icons/hicolor/${res}x${res}/mimetypes/*.png \
	  	$PKG/$LO_PREFIX/share/icons/hicolor/${res}x${res}/mimetypes
	done
 
	rm -rf $PKG/gid*
    cp -R $SRC/flat_logo.svg $PKG/usr/lib/libreoffice/program/flat_logo.svg
    cp -R $SRC/intro.png $PKG/usr/lib/libreoffice/program/intro.png
    cp -R $SRC/*.desktop $PKG/usr/lib/libreoffice/share/xdg/
    mkdir -p $PKG/tmp
    mv $SRC/libreoffice $PKG/tmp/
}

